let app = getApp();
import {
    ajaxPost,
    showToast
} from '../../../../utils/util'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        WEBURL: app.globalData.WEBURL,
        userSource: {},
        codeImg: ''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getUser()
    },
    /**
     * 获取个人信息
     */
    getUser() {
        let data = {
            token: wx.getStorageSync("token"),
        }
        ajaxPost("/authuser/myInfo", data, (res) => {
            if (res.code == 0) {
                this.setData({
                    userSource: res.data.user_info
                })
                this.getCodeImg()
            } else {
                showToast('text', res.msg);
            }
        });
    },
    /**
     * 获取二维码
     */
    getCodeImg() {
        let data = {
            token: wx.getStorageSync("token"),
            url: `/pages/share/share?identity=enterprise&type=code&shareId=${this.data.userSource.uid}`,
        }
        ajaxPost('/authuser/resumeCode', data, res => {
            if (res.code == 0) {
                this.setData({
                    codeImg: res.data.url
                })
            } else {
                showToast('text', res.msg)
            }

        })
    },

})